/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package database;

import java.sql.Timestamp;
import java.util.List;
import utils.Debug;

/**
 *
 * @author daz
 */
public class Runner {
// test connection

    private static DataEngine dataEngine = DataEngine.getInstance();

    public static void main(String[] args) {
        dataEngine.connectToDabatabase();
        System.out.println("test connection :" + dataEngine.testConnection());
//        testUnicode();
//        testInsertNewMessage();
//        testInsertNewMessage();
//        testGetListMessage();
        testGetListUser();
    }

    public static void testGetListUser() {
        List<UserInfo> list = dataEngine.getListUser(10);
        Debug.d("info :" + list.get(1).getUserPassword());
    }

    public static void testActivateAcc() {
        dataEngine.activateAcc("gjmptw");
    }

    public static void testGetSmsQueue() {
        List<SmsInfo> list = dataEngine.getSmsQueue();
        if (list.isEmpty()) {
            Debug.d("ko co");
        } else {
            for (int i = 0; i < list.size(); i++) {
                Debug.d("sms :" + list.get(i).getSmsInfo());
            }
        }
    }

    public static void testSetRead() {
        dataEngine.setReadMessage("nam456", "nu1234", Timestamp.valueOf("2012-07-10 00:06:27"));
    }

    public static void testInsertFamilyInfo() {
        dataEngine.insertChild(1, "test", 0);
    }

    public static void testDeleteMessage() {
        dataEngine.deleteMessage("abc", "bcd", Timestamp.valueOf("2012-07-08 00:11:51"));
    }

    public static void testGetListMessage() {
        List<UserMessage> list = dataEngine.getMessage("bcd");
        Debug.d("content :" + list.get(0).getMessage());
    }

    public static void testInsertNewMessage() {
        dataEngine.insertNewMessenger("abc", "bcd", "câu tiếng việt dài ngoằng", Timestamp.valueOf("2012-07-10 00:06:27"), 0);
    }

    public static void testUnicode() {
        List<Test> list = dataEngine.testUnicode();
        Debug.d("test :" + list.get(0).info);
    }

    public static void testInserChild() {
        dataEngine.insertChild(0, "test 2", 1);
    }

    public static void testDeleteItemUsed() {
        dataEngine.deleteItemUsed("chaulh", Timestamp.valueOf("2012-07-05 01:53:56"));
    }

//    public static void testActivateItem() {
//        dataEngine.activateItem(Timestamp.valueOf("2012-06-28 11:44:10"), Timestamp.valueOf(" 2012-06-28 11:44:00"), ".adgjm", 0);
//    }
    public static void testGetUserListItem() {
        List<Item> listItem = dataEngine.getUserListItem(".adgjm");
        Debug.d("start time :" + listItem.get(0).getStartingTime());
    }

//    public static void testInsertNewBuyItem() {
//        dataEngine.insertNewBuyItem(0, 0, ".adgjm");
//    }
    public static void testInsertStatus() {
        dataEngine.insertUserStatus(".adgjm", "dfasdfasdfasdfsafa");
    }

    public static void testGetTopRich() {
        List<UserInfo> list = dataEngine.getTopRich();
        for (int i = 0; i < list.size(); i++) {
            Debug.d("name :" + list.get(i).getUserName());
        }
    }

    public static void testGetListFriend() {
        List<FriendInfo> list = dataEngine.getListFriend(".adgjm");
        if (list.size() == 0) {
            Debug.d("ko co");
            return;
        }
        for (int i = 0; i < list.size(); i++) {
            Debug.d("name :" + list.get(i).getName());
        }
    }

    public static void tesCheckMaried() {
//        List<FriendInfo> list = dataEngine.checkMary("chaulhsdfd", "ronaldo");
//        if (list.size() == 0) {
//            Debug.d("ko co");
//            return;
//        }
//        Debug.d("size :" + list.size());
//        Debug.d("maried:" + list.get(0).getName());
    }

    public static void testMarry() {
        dataEngine.marry("chaulh", "ronaldo");
    }

    public static void testInsertNewFriend() {
        dataEngine.insetNewFriend("ronaldo", "messi");
    }

    public static void testUpdate() {
        dataEngine.updateWin(".adgjm", 5);
    }

    public static void testGetChildInfo() {
        List<ChildInfo> childList = dataEngine.getChildInfo(".adgjm");
        Debug.d("size :" + childList.get(0).getChildGender());
    }

    public static void testGetMateInfo() {
        MateInfo mateInfo = dataEngine.getMateInfo(".adgjm");
        Debug.d("mate :" + mateInfo.getMateName1());
    }

    public static void testUpdateMoney() {
        dataEngine.updateMoney(2000, "chaulh");
    }

    public static void testLogin(String userName) {
        UserInfo userInfo = dataEngine.getUserInfo(userName);
        if (userInfo != null) {
            System.out.println("user pass:" + userInfo.getLevel());
        } else {
            System.out.println("no result");
        }
    }

    public static void testGetUserMoney() {
        Debug.d(String.valueOf(dataEngine.getUserMoney("chaulh kagkadf;gkad;fgk;dfgk;ad kfg")));
    }

    public static void testReset() {
        dataEngine.resetUserIsplay();
    }

    public static void testSetUserOnline() {
        dataEngine.setUserOnline(0, "qwerty");
    }

    public static void testInsertUser() {
        dataEngine.insertUser("chau11", "124", "0", "0");
    }

    public static void testFindUserName() {
        List<UserInfo> list = dataEngine.findUserName("qwerdfasfdsdfdfty");
        Debug.d("list length:" + list.size());
    }
}
